#!/usr/bin/python
# This program draws 454 contig scaffolds as they are produced by Newbler
# assembler. The contig scaffolds are ordered according to the ordering system 
# from Newbler. It needs two input files: 
# 1. 454Scaffolds.txt file
# 2. MUMMER coordinate file of 454AllContigs.fna and contigs produced by
#    Velvet assembler
#    generate like this: nucmer 454AllContigs.fna velvetcontigs.fa -p prefix
# Usage: python visualize454ScaffoldGaps.py 454Scaffolds.txt file alignmentfile.txt

import sys, re

scaffile = open(sys.argv[1], "rU")
coordfile = open(sys.argv[2], "rU")

scaff = scaffile.readlines()
coords = coordfile.readlines()

rxscaf = re.compile('scaffold\d+')
rxctg = re.compile('contig\d+')

scaflist = []

for i in scaff:
    line = i.split('\t')
    if rxscaf.match(line[0]) and rxctg.match(line[5]):
        scafname = line[0]
        scafstart = int(line[1])
        scafstop = int(line[2])
        ctgname = line[5]
        ctgstart = int(line[6])
        ctgstop = int(line[7])
        ctgorient = line[8].strip()
        scaflist.append(scafname)

uniquescafs = list(set(scaflist))



scaffile.close()
coordfile.close()
